//
//  KFDDiscoveryViewController.m
//  
//
//  Created by JIRENTIANXIANG on 6/20/15.
//
//

#import "KFDDiscoveryViewController.h"
#import "KFDUIConfigurator.h"
#import "KFDETFHoldingsViewController.h"
#import "KFDInvestmentCommunityPostListViewController.h"
#import "KFDPreferentialActivitiesViewController.h"
//#import "KFDIndexViewController.h"
#import "KFDChooseTeacherViewController.h"
#import "KFDAccountManager.h"

@interface KFDDiscoveryViewController ()

@end

@implementation KFDDiscoveryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    KFDUIConfigurator* uiConfigurator=[KFDUIConfigurator configuratorForViewController:self];
    [uiConfigurator configureNavigationBar];
    self.title=@"发现";
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view delegate

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
        case 0:
        {
            UIViewController* investmentCommunityPostListVC=[[KFDInvestmentCommunityPostListViewController alloc] init];
            [self.navigationController pushViewController:investmentCommunityPostListVC animated:YES];
            break;
        }
        case 1:
        {
            switch (indexPath.row) {
                case 0:
                {
                    UIViewController* etfHoldingVC=[[KFDETFHoldingsViewController alloc] init];
                    [self.navigationController pushViewController:etfHoldingVC animated:YES];
                    break;
                }
//                case 1:
//                {
//                    UIViewController* kfdIndxVC=[[KFDIndexViewController alloc] init];
//                    [self.navigationController pushViewController:kfdIndxVC animated:YES];
//                    break;
//                }
            }
            break;
        }
        case 2:
        {
            switch (indexPath.row) {
                case 0:
                {
                    UIViewController* preferentialActivitiesVC=[[KFDPreferentialActivitiesViewController alloc] init];
                    [self.navigationController pushViewController:preferentialActivitiesVC animated:YES];
                    break;
                }
                case 1:
                {
                    KFDAccountManager* accountManager=[KFDAccountManager sharedManager];
                    if (accountManager.isVIP) {
                        UIViewController* chooseTeacherVC=[[KFDChooseTeacherViewController alloc] init];
                        [self.navigationController pushViewController:chooseTeacherVC animated:YES];
                    }else{
                        UIViewController* vipServiceVC=[[UIStoryboard storyboardWithName:@"VIPService" bundle:nil] instantiateViewControllerWithIdentifier:@"KFDVIPServiceViewController"];
                        [self.navigationController pushViewController:vipServiceVC animated:YES];
                    }
                }
            }
            break;
        }
    }
}

@end
